from django.db import models
import datetime

# Create your models here.
from django.db import models
import django.utils.timezone as timezone


class OncallInfo(models.Model):
    '''
         oncall表
    '''
    dev_group = models.CharField(max_length=64, verbose_name="开发组", help_text="开发组")
    sm = models.CharField(max_length=64, verbose_name="经理", help_text="经理")
    oncaller = models.CharField(max_length=64, verbose_name="值班人员", help_text="值班人员")
    oncaller_mobile = models.CharField(max_length=64, verbose_name="电话", help_text="电话")
    start_time = models.DateField(verbose_name='开始日期', default=timezone.now)
    end_time = models.DateField(verbose_name='结束日期')
    created_by = models.CharField(max_length=64, verbose_name="创建人员", help_text="创建人员")
    updated_by = models.CharField(max_length=64, verbose_name="更新人员", help_text="更新人员")
    created_time = models.DateTimeField(verbose_name="创建日期", auto_now_add=True)
    updated_time = models.DateTimeField(verbose_name="更新日期", auto_now=True)

    class Meta:
        db_table = 'oc_table'             #指明数据库中的表名
        verbose_name = 'oncall值班信息'               #在admin站点中显示的名称

    def time(self):
        starttime = datetime.datetime.date(self.start_time)
        end_time = datetime.datetime.date(self.end_time)
        return {starttime, end_time}



